import { Dialog } from "./Dialog";
import * as PIXI from 'pixi.js';
import * as UI from '@pixi/ui'
import { $t } from "../../plugins/i18n";
import { TopMenus } from "./config";
export class NodesMenus extends Dialog {
    public onClick = (_:string)=>{}
    constructor() {
        super()
        this.onReady = this.ready
    }
    private ready(){
        TopMenus.add.forEach(key => {
            const nodeBox = new PIXI.Container()
            const nodeBg = new PIXI.Graphics()
            const text = new PIXI.Text({
                text: $t(key),
                style: {
                    fontSize: 16,
                    fill: 0xffffff
                }
            })
            text.x = 5
            text.y = 5
            const rect = text.getLocalBounds()
            nodeBg.roundRect(1, 2, rect.width + 10, rect.height + 10, 5)
            nodeBg.fill({
                color: 0x1b2350
            })
            nodeBg.beginPath()
            nodeBg.roundRect(0, 0, rect.width + 10, rect.height + 10, 5)
            nodeBg.fill({
                color: 0x344395
            })

            nodeBox.addChild(nodeBg)
            nodeBox.addChild(text)
            const btn = new UI.Button(nodeBox)


            btn.onPress.connect(() => {
                this.hide()
                this.onClick(key)
            })
            btn.onHover.connect(() => {
                nodeBg.alpha = 0.5
            })
            btn.onOut.connect(() => {
                nodeBg.alpha = 1
            })
        this.scrollBox.addItem(btn.view)
        })
    }
}